<template>
    <view class="content">
        <view class="box">
            <view class="item">
                <view class="grey">订单类型</view>
                <view class="item-right">
                    <view class="role-btn" :class="{roleActive : role == 1}" @click="role = 1">零担</view>
                    <view class="role-btn" :class="{roleActive : role == 2}" @click="role = 2">包车</view>
                </view>
            </view>
        </view>

        <view class="box u-p-b-20">
            <view class="work-title">运输线路</view>
            <view class="item" @click="show_1 = true">
                <view class="grey">选择线路</view>
                <view class="item-right">
                    <text style="color: grey;font-size: 28rpx;" v-if="!lineData.name">请选择运输线路</text>
                    <text v-else>{{lineData.name}}</text>

                </view>
                <u-icon name="arrow-right" color="#979797" size="28" class="u-m-l-5"></u-icon>
            </view>
            <view class="item" v-if="lineData.origin">
                <view class="grey">始发地</view>

                <view class="item-right">{{lineData.origin}}</view>
            </view>

            <view class="item" v-if="lineData.destination">
                <view class="grey">目的地</view>
                <view class="item-right">{{lineData.destination}}</view>
            </view>
            <view class="item" v-if="lineData.loading_site">
                <view class="grey">装车地点</view>
                <view class="item-right">{{lineData.loading_site}}</view>
            </view>

            <view class="item u-p-b-10" v-if="lineData.start_time">
                <view class="grey">发车日期</view>
                <view class="item-right" @click="show_2 = true">
                    <!-- <input type="text" v-model="date" placeholder="请选择" class="inp" disabled> -->

                    <text style="color: grey;font-size: 28rpx;" v-if="!date">请选择</text>
                    <text v-else>{{date}}</text>


                    <u-icon name="arrow-right" color="#979797" size="28" class="u-m-l-5"></u-icon>
                </view>
            </view>

            <view class="item u-p-b-10">
                <view class="grey">发车时间</view>
                <view class="item-right" @click="show_3 = true">

                    <!-- <input type="text" v-model="time" placeholder="请选择" class="inp" disabled> -->

                    <text style="color: grey;font-size: 28rpx;" v-if="!time">请选择</text>
                    <text v-else>{{time}}</text>

                    <u-icon name="arrow-right" color="#979797" size="28" class="u-m-l-5"></u-icon>

                </view>
            </view>
            <view class="price2" v-if="lineData.start_time">
                <view class="tip2">温馨提示: {{ lineData.start_time }}点 以后不发车</view>
            </view>
        </view>

        <view class="box" v-if="role == 2">
            <view class="item">
                <view class="grey">车辆类型</view>
                <view class="item-right" @click="openCarType">

                    <text style="color: grey;font-size: 28rpx;" v-if="!car">请选择车辆类型</text>
                    <text v-else>{{car}}</text>
                    <!-- <input type="text" v-model="car" placeholder="请选择车辆类型" class="inp" disabled> -->
                    <u-icon name="arrow-right" color="#979797" size="28" class="u-m-l-5"></u-icon>
                </view>
            </view>
            <view class="item">
                <view class="grey">车长</view>
                <view class="item-right" @click="openCarLen">
                    <text style="color: grey;font-size: 28rpx;" v-if="!carLen">请选择车长</text>
                    <text v-else>{{carLen}}</text>
                    <!-- <input type="text" v-model="carLen" placeholder="请选择车长" class="inp" disabled> -->
                    <u-icon name="arrow-right" color="#979797" size="28" class="u-m-l-5"></u-icon>
                </view>
            </view>
            <view class="price">
                <view>
                    运费
                    <text v-if="freight > 0">
                        <text class="price-num">{{ freight }}</text>元
                    </text>
                    <text class="u-p-l-15" v-else>自动计算</text>
                </view>
            </view>
        </view>

        <view class="box">
            <view class="box-top">
                <view class="s-icon">收</view>
                <view class="u-flex" @click="toPage(`/pages/address/take-address?from=Id`)">
                    <image src="../../static/icon/add.png" class="add-icon"></image>
                    <view>收货方地址</view>
                </view>
            </view>
            <view class="item" v-if="lineData.address">
                <view class="grey">收货地址</view>
                <view class="item-right">{{ lineData.address }}</view>
            </view>
            <view class="item u-p-b-10">
                <view class="grey">经营位置</view>
                <view class="item-right" @click="toPage(`/pages/address/take-address?from=Id`)">
                    <input type="text" v-model="takeAdd.address" placeholder="请选择" class="inp" disabled>
                    <u-icon name="arrow-right" color="#979797" size="28" class="u-m-l-5"></u-icon>
                </view>
            </view>
            <view class="item">
                <view class="grey">联系人</view>
                <view class="item-right">
                    <input type="text" v-model="takeAdd.contacts" placeholder="请输入联系人" class="inp">
                </view>
            </view>
            <view class="item">
                <view class="grey">联系方式</view>
                <view class="item-right">
                    <input type="number" v-model="takeAdd.phone" placeholder="请输入联系方式" class="inp">
                </view>
            </view>
        </view>
        <view class="box">
            <view class="box-top">
                <view class="f-icon">发</view>
                <view class="u-flex" @click="toPage(`/pages/address/send-address`)">
                    <image src="../../static/icon/add.png" class="add-icon"></image>
                    <view>发货方地址</view>
                </view>
            </view>
            <view class="item u-p-b-10">
                <view class="grey">发货方</view>
                <view class="item-right" @click="toPage(`/pages/address/send-address`)">
                    <input type="text" v-model="sendAdd.name" placeholder="请选择" class="inp" disabled>
                    <u-icon name="arrow-right" color="#979797" size="28" class="u-m-l-5"></u-icon>
                </view>
            </view>
            <view class="item">
                <view class="grey">联系人</view>
                <view class="item-right">
                    <input type="text" v-model="sendAdd.contacts" placeholder="请输入联系人" class="inp">
                </view>
            </view>
            <view class="item">
                <view class="grey">联系方式</view>
                <view class="item-right">
                    <input type="number" v-model="sendAdd.phone" placeholder="请输入联系方式" class="inp">
                </view>
            </view>

            <view class="item">
                <view class="grey">上传货物清单图</view>
                <view class="item-right" style="position: relative;" @click="chooseImage">
                    <image v-if="!inageData.image_id" src="../../static/image/up.png" class="up"></image>
                    <image v-else :src="inageData.image" class="up" mode="widthFix"></image>
                    <view v-if="inageData.image_id" @click.stop="previewImage()"
                        style="position: absolute;bottom: 0;width: 180rpx;right: 0;text-align: center;background:rgba(0, 0, 0, 0.4);color: #fff;">
                        查看</view>

                </view>
            </view>

            <view class="item-col">
                <view class="grey">地址备注</view>
                <textarea maxlength="200" v-model="remark" :auto-height="true" placeholder="请输入地址备注信息"
                    class="t-inp"></textarea>
            </view>
        </view>

        <view class="btn" @click="$noMultipleClicks(next)">下一步</view>
        <!-- 运输线路 -->
        <u-select v-model="show_1" mode="single-column" :list="select.line" label-name="name" value-name="id"
            @confirm="confirm($event, 1)"></u-select>
        <u-picker v-model="show_2" mode="time" @confirm="confirm($event, 2)"></u-picker>
        <!-- 发车时间 -->
        <template v-if="show_3">
            <u-select v-model="show_3" mode="single-column" :list="timeList" @confirm="confirm($event, 3)"></u-select>
        </template>
        <!-- 车辆类型 -->
        <template v-if="show_4">
            <u-select v-model="show_4" mode="single-column" :list="carList" label-name="name" value-name="id"
                @confirm="confirm($event, 4)"></u-select>
        </template>

        <u-select v-model="show_5" mode="single-column" :list="carLenList" label-name="name" value-name="id"
            @confirm="confirm($event, 5)"></u-select>
        <!-- 底部导航 -->
        <u-tabbar v-model="current" :list="tab_list" active-color="#00457f" inactive-color="#5d5f6a" :border-top="true"
            @change="tabbarChange"></u-tabbar>
    </view>
</template>

<script>
    export default {
        data() {
            return {

                current: 0, //底部导航索引
                tab_list: [],
                identity: '', //4发货 5卸货

                role: 1, //零担 2包车

                select: {}, //下拉选项


                noClick: true, //连点

                takeAdd: {}, //收获方地址
                sendAdd: {}, //发获地址
                remark: '', //地址备注

                show_1: false, //运输线路\
                show_2: false,
                show_3: false,
                show_4: false, //车辆类型
                show_5: false, //车长

                timeList: [], //发车时间
                lineData: {
                },
                date: '', //发车日期


                freight: 0, //运费
                carList: [], //车辆类型
                car: '',
                carId: '',
                carLenList: [], //车长
                carLen: '',
                carLenId: '',
                inageData: {},
                order_id_again: '',
                isAgain: '', //1是再来一单


                time: '',
                address: '',

                order_id: ''


            };
        },
        onLoad(option) {

            // 从我的订单进入
            if (option.order_id_again) {
                this.order_id_again = option.order_id_again
            }
            



            // 接收收货方地址
            uni.$on('CHOOSE_TAKE_ADD', data => {
				console.log('CHOOSE_TAKE_ADD', data)
                this.takeAdd = data
            })

            // 接收发货方地址
            uni.$on('CHOOSE_SEND_ADD', data => {
                this.sendAdd = data
            })
            
            let myDate = new Date();
            // let Year = myDate.getFullYear();  //获取完整的年份(4位,1970-????)
            // let Month = myDate.getMonth()+1;  //获取当前月份(0-11,0代表1月)
            // let Dates = myDate.getDay();  //获取当前日(1-31)
            let Dates = myDate.toLocaleDateString()
            Dates = Dates.replaceAll("/", "-");
            this.date =Dates
        },
        onShow() {
            // 身份
            // if (!this.$getSync('identity')) {
            //     this.$setSync('identity', 4)
            //     this.identity = 4;
            //     this.tabbarInfo();
            // } else {
            //     this.identity = this.$getSync('identity');
            //     this.tabbarInfo();
            // }
            
            
            // 身份
            if(!this.$getTokens()){
                this.$gTo('/pages/login/login');
            }else{
                this.identity = this.$getSync('identity');
                this.tabbarInfo();
                
            }
            
            
            if (this.$getSync('order_id_again')) {
                this.order_id_again = this.$getSync('order_id_again');
                this.isAgain = this.order_id_again.id
                this.getData()
            }
        },
        
        onTabItemTap : function(e) {
        	
            this.current = 0; //底部导航索引
            this.tab_list = [];
            this.identity = ''; //4发货 5卸货
            
            this.role = 1; //零担 2包车
            
            this.select = {}; //下拉选项
            
            
            this.noClick = true; //连点
            
            this.takeAdd = {}; //收获方地址
            this.sendAdd = {}; //发获地址
            this.remark = ''; //地址备注
            
            this.show_1 = false; //运输线路\
            this.show_2 = false;
            this.show_3 = false;
            this.show_4 = false; //车辆类型
            this.show_5 = false; //车长
            
            this.timeList = []; //发车时间
            this.lineData = {};
            this.date = ''; //发车日期
            
            
            this.freight = 0; //运费
            this.carList = []; //车辆类型
            this.car = '';
            this.carId = '';
            this.carLenList = []; //车长
            this.carLen = '';
            this.carLenId = '';
            this.inageData = {
                
            };
            this.order_id_again = '';
            this.isAgain = ''; //1是再来一单
            
            
            this.time = '';
            this.address = '';
            
            this.order_id = '';
        },
        
        methods: {
            
            previewImage() {
                let url = []

                url[0] = this.inageData.image
                uni.previewImage({
                    urls: url,
                    longPressActions: {
                        success: function(data) {},
                        fail: function(err) {
                            console.log(err.errMsg);
                        }
                        
                    }
                });
            },

            chooseImage() {
                let _this = this
                uni.chooseImage({
                    count: 1, //默认9
                    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
                    sourceType: ['album','camera'], //从相册选择
                    success: function(res) {
                        _this.$upLoadPic(res.tempFilePaths[0]).then(data => {
                            _this.inageData = data.detail;
                            // item.default_value.push(data.data);
                        });

                    }
                });

            },
            // 获取第一步订单详情
            getData() {
                console.log(this.order_id_again)
                this.$ajax('another_order', {
                    user_token: this.$getSync('token'),
                    order_id: this.order_id_again.id, //订单id
                }).then(ret => {
                     this.$setSync('order_id_again','')
                    if (ret.success == 1000) {
                        let data = ret.detail
                        this.role = data.user_type;
                        
                        this.lineData.id = data.line_id
                        this.lineData.name = data.line
                        this.lineData.origin = data.origin
                        this.lineData.destination = data.destination
                        this.lineData.loading_site = data.loading_site
                        
                        this.date = data.start_date
                        this.time = data.start_time
                        
                        this.inageData.image = data.image;
                        this.inageData.image_id = data.image_id;
                        
                        this.lineData.address = data.address //线路选择后返回的

                        this.select.line.forEach(cur => {
                            if (cur.id == this.lineData.id) {
                                this.lineData.loading_time = cur.loading_time
                                this.lineData.start_time = cur.start_time
                            }
                        })

                        // 生成发车时间列表
                        let a = this.lineData.loading_time.split(":")[0]
                        let aa
                        if (a < 10) {
                            aa = a.slice(1)
                        } else {
                            aa = a
                        }
                        let b = this.lineData.start_time.split(":")[0]
                        let c = Number(b) + 1
                        for (let i = aa; i < c; i++) {
                            let lab = i < 10 ? '0' + i : i
                            this.timeList.push({
                                value: i,
                                label: lab + ':00'
                            })
                        }

                        this.car = data.vehicle
                        this.carId = data.vehicle_id
                        this.carLen = data.length
                        this.carLenId = data.length_id
                        this.freight = data.freight;
                        
                        

                        this.takeAdd.id = data.recipient_id
                        this.takeAdd.address = data.position
                        this.takeAdd.contacts = data.recipient_contact
                        this.takeAdd.phone = data.recipient_phone

                        this.sendAdd.id = data.shipper_id
                        this.sendAdd.name = data.shipper
                        this.sendAdd.contacts = data.shipper_contact
                        this.sendAdd.phone = data.shipper_phone

                        this.remark = data.remark

                        this.getCarType()
                        this.getCarlength()
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },

            // line 线路 shipper默认发货方 recipient 默认收货方
            getSelect() {
                this.$ajax('select_line', {
                    user_token: this.$getSync('token'),
                }).then(ret => {
                    if (ret.success == 1000) {
                        this.select = ret.detail
                        if (!this.order_id_again) {
                            if (ret.detail && ret.detail.recipient && ret.detail.recipient[0] && !this.takeAdd.id) {
                                this.takeAdd = ret.detail.recipient[0]
                            }
                            if (ret.detail && ret.detail.shipper && ret.detail.shipper[0] && !this.sendAdd.id) {
                                this.sendAdd = ret.detail.shipper[0]
                            }
							
							this.car = ''
							this.carId = ''
							this.carLen = ''
							this.carLenId = ''
							this.freight = 0
							
							let line = ret.detail && ret.detail.line && ret.detail.line[0]
							this.lineData = {
								id: line.id,
								name: line.name,
								origin: line.origin,
								destination: line.destination,
								loading_site: line.loading_site,
								address: line.address,//线路选择后返回的
								start_time: line.start_time,
								loading_time: line.loading_time,
							}
							
							this.getCarType()
							// 生成发车时间列表
							let a = this.lineData.loading_time.split(":")[0]
							let aa
							if (a < 10) {
							    aa = a.slice(1)
							} else {
							    aa = a
							}
							let b = this.lineData.start_time.split(":")[0]
							let c = Number(b) + 1
							for (let i = aa; i < c; i++) {
							    let lab = i < 10 ? '0' + i : i
							    this.timeList.push({
							        value: i,
							        label: lab + ':00'
							    })
							}
                        } else {
                            this.getData()
                        }
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },

            openCarLen() {
                if (!this.carId) {
                    this.$toast('请先选择车辆类型')
                    return
                } else {
                    this.show_5 = true
                }
            },
            // 获取车长
            getCarlength() {
                this.$ajax('select_length', {
                    user_token: this.$getSync('token'),
                    line_id: this.lineData.id, //线路id
                    vehicle_id: this.carId, //车辆类型id
                }).then(ret => {
                    if (ret.success == 1000) {
                        this.carLenList = ret.detail
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },

            tabbarInfo() {
                // 发货
                if (this.$getSync('identity') == 4) {
                    if(this.$getSync('authority_car') == 1){
                        this.tab_list = [
                            {
                                iconPath: "/static/icon/tab_01.png",
                                selectedIconPath: "/static/icon/tab_02.png",
                                text: '首页',
                                pagePath: "/pages/tabbar/index"
                            },{
                                iconPath: "/static/icon/tab_03.png",
                                selectedIconPath: "/static/icon/tab_04.png",
                                text: '找车',
                                pagePath: "/pages/tabbar/tab-2"
                            },{
                                iconPath: "/static/icon/tab_05.png",
                                selectedIconPath: "/static/icon/tab_06.png",
                                text: '发货',
                                pagePath: "/pages/tabbar/tab-3"
                            },{
                                iconPath: "/static/icon/tab_07.png",
                                selectedIconPath: "/static/icon/tab_08.png",
                                text: '下单',
                                pagePath: "/pages/tabbar/tab-4"
                            },{
                                iconPath: "/static/icon/tab_09.png",
                                selectedIconPath: "/static/icon/tab_10.png",
                                text: '我的',
                                pagePath: "/pages/tabbar/mine"
                            }
                        ];
                    }else{
                        this.tab_list = [
                            {
                                iconPath: "/static/icon/tab_01.png",
                                selectedIconPath: "/static/icon/tab_02.png",
                                text: '首页',
                                pagePath: "/pages/tabbar/index"
                            },{
                                iconPath: "/static/icon/tab_05.png",
                                selectedIconPath: "/static/icon/tab_06.png",
                                text: '发货',
                                pagePath: "/pages/tabbar/tab-3"
                            },{
                                iconPath: "/static/icon/tab_07.png",
                                selectedIconPath: "/static/icon/tab_08.png",
                                text: '下单',
                                pagePath: "/pages/tabbar/tab-4"
                            },{
                                iconPath: "/static/icon/tab_09.png",
                                selectedIconPath: "/static/icon/tab_10.png",
                                text: '我的',
                                pagePath: "/pages/tabbar/mine"
                            }
                        ];
                    }
                    
                    this.getSelect()

                }

                // 卸货
                if (this.$getSync('identity') == 5) {
                    this.tab_list = [{
                        iconPath: "/static/icon/tab_01.png",
                        selectedIconPath: "/static/icon/tab_02.png",
                        text: '首页',
                        pagePath: "/pages/tabbar/index"
                    }, {
                        iconPath: "/static/icon/tab_11.png",
                        selectedIconPath: "/static/icon/tab_12.png",
                        text: '扫码卸车',
                        pagePath: "/pages/tabbar/tab-2"
                    }, {
                        iconPath: "/static/icon/tab_09.png",
                        selectedIconPath: "/static/icon/tab_10.png",
                        text: '我的',
                        pagePath: "/pages/tabbar/mine"
                    }];
                }
            },

            confirm(e, num) {
                console.log(e);
                const currentDate = new Date();
                const year = currentDate.getFullYear();
                const month = currentDate.getMonth() + 1; // 月份从0开始，需要加1
                const day = currentDate.getDate();
                const now = new Date(year + '-' + (month > 10 ? month : '0' + month) + '-' + (day > 10 ? day : '0' +
                    day)) //当前日期

                if (num == 1) {
                    // 选择运输线路
                    this.car = ''
                    this.carId = ''
                    this.carLen = ''
                    this.carLenId = ''
                    this.freight = 0

                    this.select.line.forEach(cur => {
                        if (cur.id == e[0].value) {
                            this.lineData = cur
                            this.time = cur.start_time
                        }
                    })
                    this.getCarType()
                    // 生成发车时间列表
                    let a = this.lineData.loading_time.split(":")[0]
                    let aa
                    if (a < 10) {
                        aa = a.slice(1)
                    } else {
                        aa = a
                    }
                    let b = this.lineData.start_time.split(":")[0]
                    let c = Number(b) + 1
                    for (let i = aa; i < c; i++) {
                        let lab = i < 10 ? '0' + i : i
                        this.timeList.push({
                            value: i,
                            label: lab + ':00'
                        })
                    }
                } else if (num == 2) {
                    // 选择发车日期
                    let date = new Date(e.year + '-' + e.month + '-' + e.day) //选择日期

                    if (date < now) {
                        this.$toast('不能选择过去的日期')
                        return
                    } else if (date > now) {
                        this.timestamp = e.timestamp * 1000
                        this.date = e.year + '-' + e.month + '-' + e.day
                    } else {
                        this.timestamp = e.timestamp * 1000
                        this.date = e.year + '-' + e.month + '-' + e.day
                        this.time = ''
                    }

                } else if (num == 3) {
                    // 选择发车时间
                    let date = new Date(this.date).getTime() //选择日期
                    let nowstamp = now.getTime()

                    if (date == nowstamp) {
                        // 如果是当天，判断发车时间 不能 小于当前时间
                        let currentTime = new Date();
                        let nowh = currentTime.getHours(); //当前 小时
                        let hours = Number(e[0].value) //选择的小时
                        // console.log(hours,nowh)
                        if (nowh >= hours) {
                            this.$toast('不能选择过去的时间')
                            return
                        } else {
                            this.time = e[0].label
                        }
                    } else {
                        this.time = e[0].label
                    }
                } else if (num == 4) {
                    // 车辆类型
                    this.car = e[0].label
                    this.carId = e[0].value
                    this.carLen = ''
                    this.carLenId = ''
                    this.freight = 0
                    this.getCarlength()
                } else if (num == 5) {
                    // 车长
                    this.carLen = e[0].label
                    this.carLenId = e[0].value
                    this.getFreight()
                }
            },
            openCarType() {
                if (!this.lineData.id) {
                    this.$toast('请先选择运输线路')
                    return
                } else {
                    this.show_4 = true
                }
            },

            // 获取运费
            getFreight() {
                this.$ajax('select_freight', {
                    user_token: this.$getSync('token'),
                    line_id: this.lineData.id, //线路id
                    vehicle_id: this.carId, //车辆类型id
                    length_id: this.carLenId, //车长id
                }).then(ret => {
                    if (ret.success == 1000) {
                        this.freight = ret.detail.freight
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },

            // 获取车辆类型
            getCarType() {
                this.$ajax('select_vehicle', {
                    user_token: this.$getSync('token'),
                    line_id: this.lineData.id, //线路id
                }).then(ret => {
                    if (ret.success == 1000) {
                        this.carList = ret.detail
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },

            next() {
                if (!this.lineData.id) {
                    this.$toast('请选择运输线路')
                    return
                }
                if (!this.date) {
                    this.$toast('请选择发车日期')
                    return
                }
                // if (!this.time) {
                //     this.$toast('请选择发车时间')
                //     return
                // }
                let start_time = this.date + ' ' + this.time
                if (this.role == 2) {
                    if (!this.carId) {
                        this.$toast('请选择车辆类型')
                        return
                    }
                    if (!this.carLenId) {
                        this.$toast('请选择车长')
                        return
                    }
                }

                if (!this.takeAdd.id) {
                    this.$toast('请选择收货方地址')
                    return
                }
                if (!this.takeAdd.contacts) {
                    this.$toast('请输入收货方联系人')
                    return
                }
                if (!this.takeAdd.phone) {
                    this.$toast('请输入收货方联系方式')
                    return
                }
                // if (!this.$checkPhone(this.takeAdd.phone)) {
                //     this.$toast('请输入正确的收货方联系方式')
                //     return
                // }

                if (!this.sendAdd.id) {
                    this.$toast('请选择发货方地址')
                    return
                }
                if (!this.sendAdd.contacts) {
                    this.$toast('请输入发货方联系人')
                    return
                }
                if (!this.sendAdd.phone) {
                    this.$toast('请输入发货方联系方式')
                    return
                }
                // if (!this.$checkPhone(this.sendAdd.phone)) {
                //     this.$toast('请输入正确的发货方联系方式')
                //     return
                // }

                this.$ajax('insert_order_first', {
                    user_token: this.$getSync('token'),
                    order_type: this.role, //1零担 2包车
                    line_id: this.lineData.id, //线路id
                    start_time: start_time, //发车时间
                    user_type: this.role, //1发货方 2收货方
                    recipient_id: this.takeAdd.id, //收货方id
                    recipient_contact: this.takeAdd.contacts, //收货方联系人
                    recipient_phone: this.takeAdd.phone, //收货方联系方式
                    shipper_id: this.sendAdd.id, //发货方id
                    shipper_contact: this.sendAdd.contacts, //发货方联系人
                    shipper_phone: this.sendAdd.phone, //发货方联系方式
                    image_id: this.inageData.image_id, //图片id
                    remark: this.remark, //备注
                    vehicle_id: this.carId, //车辆类型id 包车
                    length_id: this.carLenId, //车长id 包车
                    order_id: this.order_id, //订单id
                }).then(ret => {
                    console.log(ret)
                    if (ret.success == 1000) {
                        this.order_id = ret.detail.order_id
                        this.isChooseAdd = 0
                        // if(this.role==1){
                        //     this.$gTo(`/pages/ld-send/ld-send?order_id=${ret.detail.order_id}&isAgain=${this.isAgain}&order_id_again=${this.order_id_again}`)
                        // }else{

                        // }
                        
                        
                        console.log(this.order_id_again)
                        this.$gTo(
                            `/pages/bus/bus?order_id=${ret.detail.order_id}&isAgain=${this.isAgain}&order_id_again=${this.order_id_again.id}&role=${this.role}`
                            )

                        // if (this.role == 1) {
                        // 	this.$gTo(`/pages/ld-send/ld-send?order_id=${ret.detail.order_id}&isAgain=${this.isAgain}&order_id_again=${this.order_id_again}`)
                        // } else {
                        // }
                    } else {
                        this.$toast(ret.msg);
                    }
                });

                // if (this.role == 1) {
                // 	this.$gTo(`/pages/ld-send/ld-send?order_id=${ret.detail.order_id}`)
                // } else {
                // 	this.$gTo(`/pages/bus/bus?order_id=${ret.detail.order_id}`)
                // }
            },

            toPage(url) {
                this.isChooseAdd = 1
                this.$gTo(url)
            },


            //切换底部导航
            tabbarChange(e) {
                this.current = e;
            },

        }
    };
</script>

<style lang="scss">
    .up {
        width: 180rpx;
        height: 180rpx;
    }

    .role-btn {
        padding: 15rpx 40rpx;
        background-color: #f2f4fa;
        border-radius: 50rpx;
        margin-left: 20rpx;
    }

    .roleActive {
        color: #fff;
        background-color: #0075cf;
    }

    page {
        background-color: #f2f4fa;
    }

    .content {
        // height: 100vh;
        // display: flex;
        // flex-direction: column;
        // justify-content: space-between;
        padding: 30rpx 20rpx;
    }

    .nav2-r {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        font-size: 24rpx;
        color: #737373;
        padding-bottom: 30rpx;
        padding-right: 20rpx;
        padding-top: 20rpx;
    }

    .time {
        min-width: 210rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #000;
        margin-left: 12rpx;
        padding: 15rpx;
        background-color: #fff;
        border-radius: 10rpx;
    }

    .time-icon {
        width: 25rpx;
        height: 25rpx;
        margin-left: 20rpx;
    }

    // .box{
    //     padding: 35rpx 30rpx;
    //     margin: 0 20rpx 15rpx;
    //     background-color: #fff;
    //     border-radius: 20rpx;
    // }
    // .top{
    //     display: flex;
    //     justify-content: space-between;
    //     align-items: center;
    // }
    // .item{
    //     display: flex;
    //     justify-content: space-between;
    //     align-items: center;
    //     padding-bottom: 8rpx;
    //     font-size: 28rpx;
    // }
    // .left{
    //     width: 160rpx;
    //     color: #656565;
    // }
    // .right{
    //     flex: 1;
    //     word-break: break-all;
    //     white-space: pre-line;
    // }
    // .del-02{
    //     width: 32rpx;
    //     height: 32rpx;
    //     margin-left: 15rpx;
    // }
    // .btns{
    //     display: flex;
    //     justify-content: flex-end;
    //     align-items: center;
    // }
    // .btn1{
    //     padding: 15rpx 25rpx;
    //     background-color: #99aeca;
    //     border-radius: 50rpx;
    //     color: #fff;
    // }
    .box {
        padding: 0 30rpx;
        background-color: #fff;
        border-radius: 20rpx;
        margin-bottom: 30rpx;
    }

    .item {
        padding: 30rpx 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .work-title {
        font-size: 28rpx;
        font-weight: bold;
        padding-top: 30rpx;
    }

    .item-right {
        flex: 1;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-left: 20rpx;
        text-align: right;
    }

    .inp {
        flex: 1;
        text-align: right;
        font-size: 28rpx;
    }

    .t-inp {
        background-color: #f5f6fa;
        width: 100%;
        min-height: 180rpx;
        height: auto;
        padding: 20rpx;
        border-radius: 10rpx;
        margin-top: 20rpx;
        font-size: 28rpx;
    }

    .grey {
        color: #656565;
    }

    .price {
        padding: 30rpx 0 20rpx;
        border-top: 2rpx solid #f4f4f4;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        font-size: 28rpx;
    }

    .price-num {
        font-size: 40rpx;
        font-weight: bold;
        padding-left: 10rpx;
        padding-right: 5rpx;
    }

    .tip {
        font-size: 22rpx;
        color: #fe6a00;
        line-height: 1;
        padding: 5rpx 13rpx;
        background-color: #fdf6f0;
        border: 2rpx solid #fe6a00;
        margin-top: 8rpx;
    }

    .btn {
        font-size: 34rpx;
        color: #fff;
        text-align: center;
        padding: 25rpx;
        background-color: #00457f;
        border-radius: 50rpx;
        margin-top: 50rpx;
    }

    .btns {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-bottom: 40rpx;
    }

    .add-02 {
        width: 152rpx;
        height: 56rpx;
    }

    .del-02 {
        width: 57rpx;
        height: 57rpx;
        margin-left: 25rpx;
    }

    .pt-box {
        padding: 35rpx 30rpx;
        background-color: #fff;
        border-radius: 20rpx;
        margin-bottom: 16rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .icon-02 {
        width: 55rpx;
        height: 55rpx;
        margin-right: 15rpx;
    }

    .pt-t1 {
        font-size: 28rpx;
        font-weight: bold;
        padding-right: 20rpx;
    }

    .pt-t2 {
        font-size: 22rpx;
        color: #929292;
    }

    .pt-t3 {
        font-size: 22rpx;
        color: #ff5f2b;
    }

    .price2 {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    .tip2 {
        font-size: 22rpx;
        color: #fe6a00;
        line-height: 1;
        padding: 5rpx 13rpx;
        background-color: #fdf6f0;
        border: 2rpx solid #fe6a00;
    }

    .price {
        padding: 30rpx 0 20rpx;
        border-top: 2rpx solid #f4f4f4;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        font-size: 28rpx;
    }


    .box-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 30rpx;
        color: #0075cf;
    }

    .s-icon {
        width: 40rpx;
        height: 40rpx;
        background-color: #016efe;
        border-radius: 10rpx;
        font-size: 23rpx;
        color: #fff;
        text-align: center;
        line-height: 40rpx;
    }

    .f-icon {
        width: 40rpx;
        height: 40rpx;
        background-color: #25c49a;
        border-radius: 10rpx;
        font-size: 23rpx;
        color: #fff;
        text-align: center;
        line-height: 40rpx;
    }

    .add-icon {
        width: 23rpx;
        height: 26rpx;
        margin-right: 10rpx;
    }

    .footer {
        width: 100%;
        height: 90rpx;
        background-color: #00457f;
        font-size: 34rpx;
        color: #fff;
        text-align: center;
        line-height: 90rpx;
    }

    .item-col {
        padding: 30rpx 0;
    }

    .option {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        padding-top: 10rpx;
    }

    .o-i {
        background-color: #f5f5f5;
        border-radius: 20rpx;
        padding: 20rpx 45rpx;
        margin-top: 13rpx;
        margin-right: 13rpx;
    }

    .active {
        color: #0075cf;
        background-color: #f1f8ff;
        border: 2rpx solid #0075cf;
        box-sizing: border-box;
        position: relative;
    }

    .choose-03 {
        width: 33rpx;
        height: 26rpx;
        position: absolute;
        right: 0;
        bottom: 0;
    }
</style>